package com.namo.cchcommon.exception;

import com.namo.cchcommon.api.ResultCode;
import lombok.Data;
import lombok.ToString;

/**
 * API错误异常类
 * @author WangXin
 * @date 2021/4/16 17:24
 */
@Data
@ToString
public class ApiException extends RuntimeException{
    private  Long code;
    private  String message;
    private String data;


    public ApiException(Long code, String message) {
        this.code = code;
        this.message = message;

    }

    public ApiException(ResultCode resultCode) {
        this(resultCode.getCode(), resultCode.getMessage());
    }

    public ApiException(ResultCode resultCode,String data) {
        this(resultCode.getCode(), resultCode.getMessage(),data);
    }

    public ApiException(Long code, String message,String data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public Long getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }

}
